home *** CD-ROM | disk | FTP | other *** search
/ The Journey to Wild Divine / The Journey to Wild Divine - Disc 2.iso / installers / quicktime / quicktime65pkg / contents / resources / postflight < prev    next >
Text File  |  2003-11-05  |  4KB  |  187 lines

  1. #!/usr/bin/perl
  2.  
  3. my $SYSVERS = "$ARGV[3]"."/System/Library/CoreServices/SystemVersion.plist";
  4. my $runnerPID = getppid();
  5. my $installerPID = "";
  6. my $uid = "";
  7. my $uname = "";
  8.  
  9. open( PSOUT, "/bin/ps -axww -o pid,ppid -p $runnerPID |" );
  10. while( <PSOUT> ) {
  11.     my @fields = split '\s+', $_;
  12.     if ("$fields[1]" eq "$runnerPID") {
  13.         $installerPID = $fields[2];
  14.     }
  15. }
  16. close( PSOUT );
  17.  
  18. if ("$installerPID" ne "") {
  19.     open( PSOUT, "/bin/ps -axww -o pid,ruid -p $installerPID |" );
  20.     while( <PSOUT> ) {
  21.         my @fields = split '\s+', $_;
  22.         if ("$fields[1]" eq "$installerPID") {
  23.             $uid = $fields[2];
  24.         }
  25.     }
  26.     close( PSOUT );
  27. }
  28.  
  29. if ("$uid" ne "") {
  30.     open( PSOUTA, "/usr/bin/id -p $uid |" );
  31.     while( <PSOUTA> ) {
  32.         my @fields = split '\s+', $_;
  33.         if ("$fields[0]" eq "uid") {
  34.             $uname = $fields[1];
  35.         }
  36.     }
  37.     close( PSOUTA );
  38. }
  39.  
  40. ###################################################################
  41.  
  42. # Remove old unneeded quicktime pieces
  43. my $CLEANUP_SCRIPT = "$ARGV[0]" . "/Contents/Resources/cleancruft";
  44. $cmd = "\"$CLEANUP_SCRIPT\" \"$ARGV[0]\" \"$ARGV[1]\" \"$ARGV[2]\" \"$ARGV[3]\"";
  45. system( "$cmd" );
  46.  
  47. ########
  48.     
  49. # Stuff the installation info into the preferences for QT Updates
  50. my $INSTALL_INFO= "$ARGV[0]" . "/Contents/Resources/installinfo";
  51. my $cmd = "\"$INSTALL_INFO\" -postinstall -volume \"$ARGV[2]\" -type full";
  52. #print STDOUT "INSTALL_INFO: $cmd\n";
  53. system( "$cmd" );
  54.  
  55. ########
  56.  
  57. # Configure the browser mime types based on the installed QuickTime
  58. my $CONFIGURE_MIME_TYPES= "$ARGV[0]" . "/Contents/Resources/ConfigureMimeTypes";
  59. my $cmd = "\"$CONFIGURE_MIME_TYPES\" -rescan -verbose";
  60. if ("$uname" ne "") {
  61.     $cmd = "sudo -u $uname \"$CONFIGURE_MIME_TYPES\" -rescan -verbose";
  62. }
  63. #print STDOUT "CONFIGURE_MIME_TYPES: $cmd\n";
  64. system( "$cmd" );
  65.  
  66. ########
  67.  
  68. #print STDOUT "BEFORE CheckVersion: $SYSVERS\n";
  69. if(CheckVersion( "$SYSVERS", "10.3", "ProductVersion", "<" )) {
  70.     # Install quicktime's version of AvailabilityMacros.h if it's there
  71.     my $INSTALL_QTFILES = "$ARGV[0]" . "/Contents/Resources/installqtfiles";
  72.     $cmd = "\"$INSTALL_QTFILES\" \"$ARGV[0]\" \"$ARGV[1]\" \"$ARGV[2]\" \"$ARGV[3]\"";
  73.     system( "$cmd" );
  74.  
  75.     # Rebase and prebind the binaries for Jaguar
  76.     my $REBASE_SCRIPT = "$ARGV[0]" . "/Contents/Resources/rebasebinaries";
  77.     $cmd = "\"$REBASE_SCRIPT\" \"$ARGV[0]\" \"$ARGV[1]\" \"$ARGV[2]\" \"$ARGV[3]\"";
  78.     system( "$cmd" );
  79.  
  80.     # Wrap the plugin in a fat container
  81.     my $WRAPPLUGIN_SCRIPT = "$ARGV[0]" . "/Contents/Resources/wrapplugin";
  82.     $cmd = "\"$WRAPPLUGIN_SCRIPT\" \"$ARGV[0]\" \"$ARGV[1]\" \"$ARGV[2]\" \"$ARGV[3]\"";
  83.     system( "$cmd" );
  84. }
  85.  
  86. ###########
  87.  
  88. my $permissions_info_file = "/tmp/com.apple.installation.savedperm";
  89. my @stat_info;
  90. my $MODE = 2;
  91. my $UID = 4;
  92. my $GID = 5;
  93.  
  94. if(-e $permissions_info_file) {
  95.     if(open(PERMS_FILE_HDL, "$permissions_info_file")) {
  96.         while(<PERMS_FILE_HDL>) {
  97.             my $item = $_;
  98.             chomp($item);
  99.             push(@stat_info, $item);
  100.         }
  101.         close(PERMS_FILE_HDL);
  102.         unlink($permissions_info_file);
  103.  
  104.         chown($stat_info[$UID], $stat_info[$GID], $TARGET_VOLUME);
  105.         chmod($stat_info[$MODE] & 07777, $TARGET_VOLUME);
  106.     }
  107. }
  108.  
  109. # NOTE:  Use this to see print when debugging
  110. #$cmd = "mkdir -p /tmp/done";
  111. #system( "$cmd" );
  112.  
  113. # Done
  114. exit(0);
  115.  
  116. ##################
  117.  
  118. sub CheckVersion
  119. {
  120.     my $path            = $_[0];
  121.     my $version         = $_[1];
  122.     my $keyName         = $_[2];
  123.     my $operator        = $_[3];
  124.  
  125.     if (! -e $path) {
  126.         return 0;
  127.     }
  128.  
  129.     if (!$operator) {
  130.         $operator = "==";
  131.     }
  132.  
  133.     my $oldSeperator = $/;
  134.     $/ = \0;
  135.  
  136.     open( PLIST, "$path") || do {
  137.         return 0;
  138.     };
  139.  
  140.     $plistData = <PLIST>;
  141.     $plistData =~ /<dict>(.*?)<\/dict>/gis;
  142.  
  143.     @items = split(/<key>/, $plistData);
  144.  
  145.     shift @items;
  146.     foreach $item (@items) {
  147.         $item =~ /(.*?)<\/key>.*?<string>(.*?)<\/string>/gis;
  148.         $versiondata{ $1 } = $2;
  149.     }
  150.  
  151.     close(PLIST);
  152.  
  153.     $/ = $oldSeperator;
  154.  
  155.     @theVersionArray = split(/\./, $versiondata{$keyName});
  156.     for ($i = 0; $i < 3; $i++) {
  157.         if(!$theVersionArray[$i]) {
  158.             $theVersionArray[$i] = '0';
  159.         }
  160.     }
  161.  
  162.     @versionArray = split(/\./, $version);
  163.     
  164.     my $actualVersion;
  165.  
  166.     for ($i = 0; $i < 3; $i++) {
  167.         if (($theVersionArray[$i] != $versionArray[$i]) or ($i == 2)) {
  168.  
  169.             $actualVersion = $theVersionArray[$i];
  170.             $version = $versionArray[$i];
  171.  
  172.             last;
  173.         }
  174.     }
  175.  
  176.     my $expression = '$actualVersion ' . $operator . ' $version';
  177.     if( eval ($expression) )
  178.     {
  179.         return 1;
  180.     }
  181.     else
  182.     {
  183.         return 0;
  184.     }
  185.  
  186. }
  187.